<%@page import="java.lang.Math;"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Conversor de Dados</title>
        <link rel="stylesheet" type="text/css" media="screen" href="16850_arquivos/activeden.css">
  <link rel="stylesheet" type="text/css" media="screen" href="16850_arquivos/widget.css">
        
        <%  String ttipo;
            double resultadoB =0;
            double resultadoBt=0;
            double resultadoMb=0;
            double resultadoGb=0;
            double resultadoTb=0;
            if(request.getParameter("tipo")!=null){
                ttipo=request.getParameter("tipo");
                if(ttipo.equals("b")){  //CONVERSÃO DE BIT
                    resultadoB=Double.parseDouble(request.getParameter("b"));
                    resultadoBt=Double.parseDouble(request.getParameter("b"))*(1.22*Math.pow(10, -4));
                    resultadoMb=Double.parseDouble(request.getParameter("b"))*(1.19*Math.pow(10, -7));
                    resultadoGb=Double.parseDouble(request.getParameter("b"))*(1.16*Math.pow(10, -10));
                    resultadoTb=Double.parseDouble(request.getParameter("b"))*(1.14*Math.pow(10, -13));
                }else if(ttipo.equals("bt")){   //CONVERSÃO DE BYTE
                    resultadoB=Double.parseDouble(request.getParameter("bt"))*8;
                    resultadoBt=Double.parseDouble(request.getParameter("bt"));
                    resultadoMb=Double.parseDouble(request.getParameter("bt"))*(9.54*Math.pow(10, -7));
                    resultadoGb=Double.parseDouble(request.getParameter("bt"))*(9.31*Math.pow(10, -10));
                    resultadoTb=Double.parseDouble(request.getParameter("bt"))*(9.09*Math.pow(10, -13));
                }else if(ttipo.equals("mb")){   //CONVERSÃO DE MEGABYTE
                    resultadoB=Double.parseDouble(request.getParameter("mb"))*(1048576*8);
                    resultadoBt=Double.parseDouble(request.getParameter("mb"))*(1048576);
                    resultadoMb=Double.parseDouble(request.getParameter("mb"));
                    resultadoGb=Double.parseDouble(request.getParameter("mb"))*(9.77*Math.pow(10, -4));
                    resultadoTb=Double.parseDouble(request.getParameter("mb"))*(9.54*Math.pow(10, -7));
                }else if(ttipo.equals("gb")){   //CONVERSÃO DE GIGABYTE
                    resultadoB= Double.parseDouble(request.getParameter("gb"))*(8589934592.00);
                    resultadoBt=Double.parseDouble(request.getParameter("gb"))*(1073741824);
                    resultadoMb=Double.parseDouble(request.getParameter("gb"))*(1024);
                    resultadoGb=Double.parseDouble(request.getParameter("gb"));
                    resultadoTb=Double.parseDouble(request.getParameter("gb"))*(9.77*Math.pow(10, -4));
                }else if(ttipo.equals("tb")){   //CONVERSÃO DE TERABYTE
                    resultadoB= Double.parseDouble(request.getParameter("tb"))*(879609302*Math.pow(10, 12));
                    resultadoBt=Double.parseDouble(request.getParameter("tb"))*(1.1*Math.pow(10, 12));
                    resultadoMb=Double.parseDouble(request.getParameter("tb"))*(1048575.91);
                    resultadoGb=Double.parseDouble(request.getParameter("tb"))*(1024);
                    resultadoTb=Double.parseDouble(request.getParameter("tb"));
                }
            }
        %>
        <script type="text/javascript">
            var ttipo='b';
        </script>
    </head>
      <header>
  <div class="container">
    <div class="account-wrapper">
    <ul id="user-account-nav">
        <li></li>
        <li>
          <div class="signin-widget hidden">
  <form action="/signin/authenticate" method="post" class="aweform vertical-form">
    <fieldset>
      <p>
        <label for="widget-username">Username</label>
        <input class="aweform" name="username" id="widget-username" tabindex="1" type="text">
      </p>
      <p>
        <label for="widget-password">Password</label>
        <input class="aweform" name="password" id="widget-password" tabindex="2" type="password">
      </p>
    </fieldset>
    <p class="forgot">
      Forgot <a href="http://activeden.net/lost_usernames">Username</a> / <a href="http://activeden.net/reset_password">Password</a>    </p>
    <button type="submit" class="btn-icon submit auto-width" tabindex="3">Sign In</button>
  </form>
</div>
        </li>
    </ul>
  </div>

  <ul class="info-nav">
    <li>
      <div class="dropdown">
        <ul>
           
        </ul>
        <ul class="meta-links">
          <li>
        </ul>
      </div>
    </li>
    <li>
      <div class="dropdown">
        <ul>
          
        </ul>
      </div>
    </li>
    </ul>
  </div>
  <!-- end .container -->
</header> <!-- end role main header -->

<nav role="navigation" class="clearfix">
  <ul class="main-nav">
    <li>
      <div class="dropdown">
            <ul>
                
            </ul>

              <ul class="meta-links">
                <li>
              </ul>
        </div>
        </li>
        <li>
          <div class="dropdown">
            <ul>
                <li>
            </ul>
            <ul class="meta-links">
              <li>
            </ul>
          </div>
        </li>
    <li class="search-container"></li>
  </ul>
</nav>


  <div class="page-info">
    <div class="container">
      <div id="breadcrumbs">\      </div>
      <h1 class="page-title">Linguagem de programação 2 - JSP - Fatec Praia Grande
      </h1>


    </div>


</div>
  <div id="content">
      <div class="container">








<div class="account-required panel shadowed" style="display: none">
 
</div>


<div class="col-s-content">
    <div class="item-preview shadowed previewholder">
        <div class="inner-boundary">
            <div class="inner-border"><span id="large_item_preview">
  <span id="large_item_preview_container">  </span> <h1>Conversor de Dados:</h1>
        <form name="frm">
            <span>Bit:     </span><input type="text" name="b"       value="<%=resultadoB%>"  onfocus="javascript:setTipo('b');"/><br>
            <span>Byte:     </span><input type="text" name="bt"     value="<%=resultadoBt%>" onfocus="javascript:setTipo('bt');" /><br>
            <span>MegaByte:</span><input type="text" name="mb" value="<%=resultadoMb%>" onfocus="javascript:setTipo('mb');" /><br>
            <span>GigaByte:</span><input type="text" name="gb" value="<%=resultadoGb%>" onfocus="javascript:setTipo('gb');" /><br>
            <span>TeraByte:</span><input type="text" name="tb" value="<%=resultadoTb%>" onfocus="javascript:setTipo('tb');" /><br><br>
            <input type="button" value="Converter" onclick="enviar()"/>
        </form>
        <script type="text/javascript">
            function setTipo(tipo){
                ttipo=tipo;
            }
            function enviar(){
                var input = document.createElement("input");
                input.setAttribute("type", "hidden");
                input.setAttribute("name", "tipo");
                input.setAttribute("value", ttipo);
                document.frm.appendChild(input);
                document.frm.submit();
            }
        </script></span>  </div>
        </div>
    </div>


        </div>
<div class="clear"><!-- --></div>


      </div>
    </div>

            <div class="clear"><!-- --></div>


  <div id="footer" class="large">
  <div class="container">
    <div class="left">
      <ul class="switcher"><li class="videohive"></li>
        <li class="three_d_ocean"></li>
   
</ul>
    </div>
    </div>
  <div class="clear"><!-- --></div>
</div>

  <div id="copyright">
  <div class="container">
    <div class="powered-by-envato">POWERED BY JOÃO FERNANDO E LEONARDO ZERTUS</div>
    <div class="copyright">
      <p>
      <span>COPYRIGHT © 2011</span>João Fernando Tarla e Leonardo Zertus</p>
    </div>
  </div>
</div>
    
</html>